import { PureComponent } from "react"

export default function lifeCycleHOC(OriginComponent) {
  class Cpn extends PureComponent {
    constructor() {
      super()
      this.startTime = new Date().getTime()
    }

    componentDidMount() {
      this.endTime = new Date().getTime()
      const current = this.endTime - this.startTime
      // 这里的.name是class类的名字，自带的，如果是函数组件，function.name也是有的
      console.log(`${OriginComponent.name}页面加载了${current}ms时间`)
    }
    render() {
      return <OriginComponent {...this.props} />
    }
  }
  return Cpn
}
